-
Notifications
You must be signed in to change notification settings - Fork 10.5k
SILGen: adjust check for optional-to-optional conversion #82099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci please smoke test |
Could you explain this further? |
It was looking through a |
I'm a bit concerned that this double- When you say that "a non-optional though may be aliased to an optional", what "aliasing" mechanism are we talking about here? Historically, I know the Clang importer logic driven by |
The new macro aliasing uncovered a latent issue where we would attempt to perform an optional-to-optional conversion on a type that is non-optional though may be aliased to an optional. `CVaList` is sometimes an optional pointer and would be interpreted as an optional type which would fail the assertion in the optional-to-optional conversion.
Sorry, I did mean extern void functionX(void);
#define function functionX This is now imported as: var function: @convention(c) () -> Void {
functionX
} This was added recently, and I don't think that the import from the ClangImporter is being worked around here. This is fixing an issue that was occurring in ICU where we see this: #define u_vformatMessage swift_u_vformatMessage
int32_t u_vformatMessage(const char *, const UChar *, int32_t, UChar, int32_t, va_list, UErrorCode); This is getting imported into Swift as: var u_vformatMessage: ... {
swift_u_vformatMessage
} Then when trying to create the va_list for a call like the following, it would abort due to the withVaList([0.0]) {
u_vformatMessage(..., $0, ...)
} ManagedValue
SILGenFunction::emitOptionalToOptional(SILLocation loc,
ManagedValue input,
SILType resultTy,
ValueTransformRef transformValue,
SGFContext C) {
...
SILType noOptResultTy = resultTy.getOptionalObjectType();
assert(noOptResultTy); // <---- this would previously trip |
@swift-ci please smoke test |
I don't think that we are seeing a double optional, but the type check treats the |
@jckarter - any more concerns? I'd like to get this in soon |
It still sounds like something fishy is going on here, but the change doesn't seem harmful and doesn't seem to break any tests, so I don't object to you landing this patch in the meantime. |
@jckarter sounds good! Is there anything I should file so that we can follow up on the investigation? Or is there something specific that would help identify a potentially better longer term solution? |
The new macro aliasing uncovered a latent issue where we would attempt to perform an optional-to-optional conversion on a type that is non-optional though may be aliased to an optional.
CVaList
is sometimes an optional pointer and would be interpreted as an optional type which would fail the assertion in the optional-to-optional conversion.